package com.project.class4_11.adapter;

/**
 * 适配器设计模式
 */
public class Test {
    public static void main(String[] args) {
        Phone phone=new Phone();
        phone.speak();
        phone.takePhoto();


    }
}
class Tel implements ISpeak{
    @Override
    public void speak(){
        System.out.println("通话功能");
    }
}
class Camera implements ICamera{
    @Override
    public void  takePhoto(){
        System.out.println("照相");
    }
}

/**
 * 类适配器
 */
//class Phone extends Tel{
//    private Camera c= new Camera();
//    public void takePhoto(){
//        c.takePhoto();
//    }
//}

interface ISpeak{
    void speak();
}
interface ICamera{
    void takePhoto();
}

/**
 * 对象适配器
 */
class Phone implements ICamera,ISpeak{
    private ISpeak speak=new Tel();
    private ICamera camera=new Camera();
    @Override
    public void speak() {
        speak.speak();
    }

    @Override
    public void takePhoto() {
        camera.takePhoto();
    }
}